import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//java标准库线程池的使用
public class demo1 {
    public static void main(String[] args) {
        //给定参数创建一个固定线程数的线程池
        ExecutorService service = Executors.newFixedThreadPool(4);
        //循环往线程池中的任务队列添加任务
        for (int i = 1;i<=100;i++) {
            int tmp = i;
            service.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println("hello  "+tmp);
                }
            });
            System.out.println(tmp);
        }

    }
}
